<!DOCTYPE html>
<meta charset="utf-8" />
<link rel="stylesheet" href="ace_v1.3/assets/css/ui.jqgrid.css" />

<div class="search_panel">
<form action="" method="post" onsubmit="return pageSearch(this);">
	<div style="display: block;" class="widget-body ">
		<div class="widget-main">
			<div class="rowt">
				<div class="col-sm-12">
					<div>
						<!--  
							<div class="table-from">
							<input id="userId" name="userId" class="search-input" type="text" autocomplete="off" placeholder="操作员账号 ...">
							<i class="ace-icon fa fa-search glyphicon-search"></i>
							</div>-->
						<div class="search_elm" style="margin-left: 0px">
							<label class="label_search">商户名称:</label>
							<div class="search_input">
								<input id="custName" type="text" name="custName" 
									placeholder="请输入商户名称">
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px;width: 220px">
							<label class="label_search">商户编号:</label>
							<div class="search_input">
								<input id="custId" type="text" name="custId" 
									placeholder="请输入商户号">
							</div>
						</div>

						<div class="search_elm" style="margin-left: 0px;width: 220px">
							<label class="label_search" for="userName">商户状态:</label>
							<div class="search_input">
							    <select 
									 rel="obj.USERSTATUS"
						 			 location="local" 
									 name="custStatus" 
						 			id="custStatus" 
						 			data-placeholder="请选择状态" style="width: 120px;vertical-align:middle;">
							<option value='' >--请选择--</option>
						 </select>
							
							</div>
						</div>
						<div class="search_elm" style="margin-left: 0px;width: 220px">
							<label class="label_search" for="userName">资金状态:</label>
							<div class="search_input">
							    <select 
									 rel="obj.ACSTATUS"
						 			 location="local" 
									 name="accountStatus" 
						 			id="accountStatus" 
						 			data-placeholder="请选择状态" style="width: 120px;vertical-align:middle;">
							<option value='' >--请选择--</option>
						 </select>
							
							</div>
						</div>
						<div class="search_button">
							<button class="btn btn-small btn_search" type="submit" title="搜索" >
								搜索
							</button>
							
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	</form>
</div>
	<div class="row">
		<div class="col-xs-12">
			<table id="grid-table"></table>

			<div id="grid-pager"></div>

			<div style="margin-top: 10px">
				<span id="auth_btn">
				
				<!-- <a class="btn btn-small btn-default"
					onclick="statusUpdate0();"> 启用
					<i class="icon-envelope"></i> 
				</a> -->
				<!-- <a class="btn btn-small btn-default"
					onclick="statusUpdate1();"> 
					<i class="icon-envelope"></i> 禁用
				</a> -->
				<a class="btn btn-small btn-warning"
					onclick="withdrawalsData();">
					<i class="icon-envelope"></i>批量提现
				</a>
				<a class="btn btn-small btn-default" href="doc/batchWithdraw_mobel.xls"
					> 模板下载<!-- 
					<i class="icon-envelope"></i> --> 
				</a>
				<a class="btn btn-small btn-warning" onclick="setPayPwd()"
					> 更改支付密码<!-- 
					<i class="icon-envelope"></i> --> 
				</a>
				</span> <span id="paging_bar" style="float: right"> </span>
			</div>

			<!-- PAGE CONTENT ENDS -->
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->

	<!-- page specific plugin scripts -->
	<script type="text/javascript">
		var jqGrid;
		jQuery(function($) {
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";

			$(window).on(
					'resize.jqGrid',
					function() {
						$(grid_selector).jqGrid('setGridWidth',
								$(".page-content").width());
					})
			var parent_column = $(grid_selector).closest('[class*="col-"]');
			$(document).on(
					'settings.ace.jqGrid',
					function(ev, event_name, collapsed) {
						if (event_name === 'sidebar_collapsed'
								|| event_name === 'main_container_fixed') {
							setTimeout(function() {
								$(grid_selector).jqGrid('setGridWidth',
										parent_column.width());
							}, 0);
						}
					})
			jQuery(grid_selector).jqGrid({

				url : "mpomng/payBalanceList/query.do",
				datatype : "json",
				height : '100%',
				width : '100%',
				colNames : [ '合作商编号','商户名称', '商户编号','商户类型', '手机号', 
				             '商户状态','上次登陆时间','可用余额','当日T1金额','待入账T1金额','总余额','是否冻结' ],
				colModel : [ 
							 {name : 'agentId',     index : 'agentId',     width : '100px' }, 
				             {name : 'custName',     index : 'custName',     width : '100px' }, 
				             {name : 'custId',       index : 'custId',       width : '120px' }, 
				             {name : 'custType',     index : 'custType',     width : '120px' , ditcKey:'CUSTTYPE', formatter : gridFormatByDict},
				             {name : 'usrMobile',    index : 'usrMobile',    width : '100px' }, 
				             {name : 'custStatus',   index : 'custStatus',   width : '80px' ,ditcKey:'USERSTATUS', formatter : gridFormatByDict}, 
				             {name : 'lastOperTime', index : 'lastOperTime', width : '150px' ,formatter : gridFormatByDate}, 
				             {name : 'acT0',  index : 'acT0',  width : '100px'}, 
				             {name : 'acT1',  index : 'acT1',  width : '100px'}, 
				             {name : 'acT1Y',  index : 'acT1Y',  width : '100px'}, 
							 {name : 'acBal',  index : 'acBal',  width : '100px'}, 
							 {name : 'accountStatus',  index : 'acBal',  width : '100px',ditcKey:'ACSTATUS', formatter : gridFormatByDict}
				            ],
				viewrecords : true,
				rowNum : 12,
				rowList : [ 12, 20, 30 ],
				altRows : true,

				shrinkToFit : false, 
				multiselect : true,//设置行可多选的 
				multiboxonly : true,//

				loadComplete : function() {
					var table = this;
					setTimeout(function() {
						//加载分页
						initPagingBar(grid_selector);
					}, 0);
				},
				beforeRequest : function() {//请求之前执行
					jqGrid = this;
				},
			});
			$(window).triggerHandler('resize.jqGrid');

			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});

			function operateEdit(cellvalue, options, rowObject){// "<div class='hidden-phone visible-desktop btn-group'>"
				
				var button = "<div class=\"hidden-sm hidden-xs btn-group\">";  //定义button
					button += "<button class='btn btn-xs btn-warning'  title='详细信息查看' onclick='selectMobile(\""+rowObject["custId"]+"\");'>详细</button>";
					/* button += "<button class='btn btn-xs btn-warning'  title='查询余额'   onclick='selectAccount(\""+rowObject["custId"]+"\");'>余额</button>"; */
				return button;
			}
			
		});


		function withdrawalsData() {
		    var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
				if (rows.length == 0) {
					msg.alert("警告", "当前没有选择数据项！", "error");
					return;
				}
				if (rows.length > 1) {
					msg.alert("警告", "不能同时选择多项数据！", "warn");
					return;
				}
				var ids = "";
				for (var i = 0; i < rows.length; i++) {
					ids += $('#grid-table').jqGrid('getRowData',rows[i]).custId+ ",";
				}
				
				ids = ids.substring(0, ids.lastIndexOf(","));
				uploadFile(ids);
				
				
		}
		function setPayPwd() {
		    var rows = $('#grid-table').jqGrid("getGridParam", "selarrrow");
			if (rows.length == 0) {
				msg.alert("警告", "当前没有选择数据项！", "error");
				return;
			}
			if (rows.length > 1) {
				msg.alert("警告", "不能同时选择多项数据！", "warn");
				return;
			}
			var ids = "";
			for (var i = 0; i < rows.length; i++) {
				ids += $('#grid-table').jqGrid('getRowData',rows[i]).custId+ ",";
			}
			
			ids = ids.substring(0, ids.lastIndexOf(","));
			
			openDialog({
				dialogId : 'dlg-setPayPwd',
				title : '修改支付密码',
				pageUrl :'mpomng/mobilemer/updatePayPwdView.do',
				width : '50%',
			    height:'50%',
			    dataParam : {
					custId : ids
				},
				dataName : 'obj,map'//表单数据存储对象名称

			}); 
		}

		function uploadFile(ids){
			openFileUpload({
				fileUploadDone:function(reslut){
					$.ajax({
						type : "post",
						url : "mpomng/legitimacy/file.do",
						data:{"fid":reslut.map.fid,"ids":ids},
						dataType : 'json',
						success : function(data) {
							if(data.rspcod==200){
								var scrWidth = document.body.scrollWidth;
								openDialog({
									dialogId : 'dlg-custAccountView',
									title : '批量提现信息',
									pageUrl :'mpomng/custPayViewByCust.do',
									width : '90%',
									height:'95%',
									pageParam : {
										dataList	:	data.obj,
										dataStr 	:	data.rspmsg
									},
									dataName : 'obj,map'//表单数据存储对象名称
								});
							}else if(data.rspcod==206){
								alert("提现金额超出可提现范围。请重新上传批量提现文件");
							}else{
								alert("文件出现异常,请检查后重新上传");
							}
						},
						error : function(XMLHttpRequest, textStatus) {
							msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
						}
					});
					
				}
			});
		}



	</script>